<?php

namespace app\services;

use app\payment\PayFactory;
use plugin\admin\app\model\AdNotify;
use plugin\admin\app\model\UserPropertyLog;

class AdService
{
    public static function reward($data)
    {
        $count = AdNotify::where('user_id', $data['jihuoniao_userId'])->count();

        $config = ConfigService::getByGroup('ad');

        if ($count >= $config['watch_ad_times']) {
            PropertyService::add($data['jihuoniao_userId'], PayFactory::SB, $config['watch_reward_coin'], UserPropertyLog::FROM_AD, $data['jihuoniao_tradeNumber']);
        }
    }
}